package com.ruoyi.old.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.data.service.ITdataHtEqService;
import com.ruoyi.data.service.ITdataHtWgService;
import com.ruoyi.data.service.ITdataRtRsService;
import com.ruoyi.data.service.ITdataRtWgcService;
import com.ruoyi.old.service.OldDataService;
import com.ruoyi.param.service.ITparamEqService;
import com.ruoyi.param.service.ITparamTmService;
import com.ruoyi.param.service.ITparamTpService;
import com.ruoyi.param.service.ITparamUeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/old/refresh")
@Api(tags = "老电表刷新接口")
public class RefreshController {

    @Autowired
    private ITdataRtRsService tdataRtRsService;

    @Autowired
    private ITdataHtEqService tdataHtEqService;

    @Autowired
    private ITdataHtWgService tdataHtWgService;

    @Autowired
    private ITdataRtWgcService tdataRtWgcService;

    @Autowired
    private ITparamEqService tparamEqService;

    @Autowired
    private ITparamTmService tparamTmService;

    @Autowired
    private ITparamTpService tparamTpService;

    @Autowired
    private ITparamUeService tparamUeService;

    @Autowired
    private OldDataService oldDataService;

    /**
     * 工作状态
     */
    @GetMapping("/rtRs")
    @ApiOperation("工作状态")
    public AjaxResult rtRs(@RequestParam("roomIds") List<String> roomIds) {
        tdataRtRsService.refresh(oldDataService.selectDataRtRsList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 房间用电量
     */
    @GetMapping("/htEq")
    @ApiOperation("房间用电量")
    public AjaxResult htEq(@RequestParam("roomIds") List<String> roomIds) {
        tdataHtEqService.refresh(oldDataService.selectDataHtEqList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 违规记录
     */
    @GetMapping("/htWg")
    @ApiOperation("违规记录")
    public AjaxResult htWg(@RequestParam("roomIds") List<String> roomIds) {
        tdataHtWgService.refresh(oldDataService.selectDataHtWgList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 违规报警
     */
    @GetMapping("/rtWgc")
    @ApiOperation("违规报警")
    public AjaxResult rtWgc(@RequestParam("roomIds") List<String> roomIds) {
        tdataRtWgcService.refresh(oldDataService.selectDataRtWgcList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 电量参数
     */
    @GetMapping("/param/eq")
    @ApiOperation("电量参数")
    public AjaxResult paramEq(@RequestParam("roomIds") List<String> roomIds) {
        tparamEqService.refresh(oldDataService.selectParamEqList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 时间参数
     */
    @GetMapping("/param/tm")
    @ApiOperation("时间参数")
    public AjaxResult paramTm(@RequestParam("roomIds") List<String> roomIds) {
        tparamTmService.refresh(oldDataService.selectParamTmList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 时段参数
     */
    @GetMapping("/param/tp")
    @ApiOperation("时段参数")
    public AjaxResult paramTp(@RequestParam("roomIds") List<String> roomIds) {
        tparamTpService.refresh(oldDataService.selectParamTpList(roomIds));
        return AjaxResult.success();
    }

    /**
     * 用电参数
     */
    @GetMapping("/param/ue")
    @ApiOperation("用电参数")
    public AjaxResult paramUe(@RequestParam("roomIds") List<String> roomIds) {
        tparamUeService.refresh(oldDataService.selectParamUeList(roomIds));
        return AjaxResult.success();
    }
}